<?php
/*
 * 视频在线查看与下载接口
 */

require_once dirname(dirname(__FILE__)) . '/include/common.inc.php';
require_once INCLUDE_ROOT_PATH . 'file_server.class.php';

$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : '';	//操作，view在线查看，download下载
$filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : '';	//要查看或下载的文件名
$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';	//token验证

if (empty($act) || empty($filename) || $token != md5('brokervideo' . $act . $filename))
{
	$result = '';
}
else
{
	$file_dir = VIDEO_ROOT_PATH;
	$filepath = $file_dir . $filename;
	$File_server = new File_server();
	
	switch ($act)
	{
		case 'view':
			if(file_exists($filepath) && is_readable($filepath)) {
				$result = $File_server->playVideo($filepath);
			}
			break;

		case 'download':
			$result = $File_server->download($filepath);
			break;

		default:
			$result = false;
			break;
	}
}
exit();
?>